{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Project 3 - Single Inheritance - Approach"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "I'm going to use an actual Python project with folders, modules, etc for this solution."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This notebook is simply detailing the sequence of steps I took to get at my final solution."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can download the full solution from the resources in this video, or (preferrably) directly from the\n",
    "[github repo](https://github.com/fbaptiste/python-deepdive)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Virtual Environment and pytest"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "I'm going to use `pytest` for testing in this project, so you should install it into your virtual environment."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Note that if you are not already using virtual environments for your projects I strongly suggest you do so."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Creating a virtual environment is incredibly easy.\n",
    "\n",
    "1. create a folder for your project\n",
    "2. create a virtual environment named `env` (or any name you prefer) by typing this in a console from inside your new folder:\n",
    "  - `python -m venv env`\n",
    "  - note: if you have both Python 2.x and 3.x installed, you'll probably need to specify it as `python3 -m venv env`\n",
    "  - you should now have a new folder called `env` inside your project folder.\n",
    "3. Next you should activate your virtual environment. How you do this will differ on Windows vs Mac/Linux:\n",
    "  - Windows: `env\\Scripts\\activate`\n",
    "  - Linux/Mac: `source env/bin/activate`\n",
    "  - Your command prompt shoudl now reflect the activation of the virtual environment something like `(env)` at the beginning of the prompt."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To deactivate a virtual environment, simply type `deactivate`."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Next we need to install the `pytest` library. We want to install `pytest` in our virtual environment, so do this after **activating** your virtual environment - make sure your prompt reflects that first.\n",
    "\n",
    "Then install `pytest` by typing this:\n",
    "`pip install -U pytest`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "That's it, you now have a virtual environment that has `pytest`."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Project Steps"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "I'm going to provide proper docstrings for every module, class, function, etc. I will use the Google style of docstrings, which is documented [here](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1. Create this folder hierarchy in the project root:\n",
    "\n",
    "```\n",
    "<project root>\n",
    "....app\n",
    "........models\n",
    "........utils\n",
    "....tests\n",
    "........unit\n",
    "```\n",
    "\n",
    "Note: there is no need to create packages (no `__init.py__`), we will simply use implicit namespace packages."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2. Create a new module (`validators.py`) inside the `app/utils` package. In that module create a helper function `validate_integer` that will allow us to validate that a value is an integer, optionally between a min and max (inclusive), and raises a `TypeError`, `ValueError` with a custom error message that can be overriden when bound checks fail."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3. Inside the `tests/unit` folder, create a new module called `test_validators.py` and create the unit tests for the `validate_integer` function."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "4. Run the unit tests and make sure all the tests pass.\n",
    "    - to run the unit tests, you can use your IDE's built-in way of doing it, or you can just use the command line, from the root of your project: \n",
    "    \n",
    "    `python -m pytest tests` \n",
    "    \n",
    "    (this will run all the tests found in that folder - you can specify more specific path to limit your tests further)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "5. In the `models` folder, create a new module file called `inventory.py`."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "6. Implement the `Resource` class"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "7. Create a new file `test_resource.py` in the `tests` folder"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "8. Create unit tests for the `Resource` class and make sure they all pass"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "9. Create `CPU` class"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "10. Unit test `CPU` class"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "11. Create `Storage` Class"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "12. Unit test `Storage` class"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "13. Create `HDD` class"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "14. Unit test `HDD` class"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "15. Create `SDD` class"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "16. Unit test `SDD` class"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
